﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.Profile;
using System.Data;
using System.Data.SqlClient;

using EHTSaleManager.Code;
using EHTSaleManager.Code.BLL;
using EHTSaleManager.Code.Utility;
using EHTSaleManager.Code.Entity;


namespace EHTSaleManager
{
    public partial class IndexListCategoty : System.Web.UI.Page
    {
        private Int32 categoryID = -1;
        private Int32 pageIndex = 1;
        private Int32 pageSize = 10;
        private Int32 totalRecord;
        protected void Page_Load(object sender, EventArgs e)
        {
            try
            {
                categoryID = Int32.Parse(Request.QueryString["CategoryID"].ToString());
                lbCategoryname.Text = CategoryProvider.GetCategoryByCategoryID(categoryID).CategoryName;
            }
            catch (Exception ex)
            {
                Form.Action = "Index.aspx";
            }

            try
            {
                pageIndex = Int32.Parse(Request.QueryString["PageIndex"].ToString());
            }
            catch (Exception)
            {
                pageIndex = 1;
            }

            pageSize = this.PaggingControl1.PageSize;
            if (!Page.IsPostBack)
            {
                LoadData(categoryID);
            }
        }
        public void LoadData(int categoryID)
        {
            dtlCategoryList.DataSource = CategoryProvider.GetAllCategorysByParentID(categoryID, pageIndex, pageSize, out totalRecord);
            dtlCategoryList.DataBind();
        }
    }
}